/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tcloudclient.UploadManager;

import api.localModel.File;
import api.localModel.LocalFileStatus;
import java.util.ArrayList;
import java.util.List;
import tcloudclient.contex.Context;
import tcloudclient.fileSystem.FileNode;

/**
 *
 * @author Tomas
 */
public class LocalFileSystemStatusBuilder {

    public LocalFileSystemStatusBuilder() {
    }
    
    public LocalFileStatus build(FileNode root){
        File generateFileStatus = generateFileStatus(root);
        return new LocalFileStatus(generateFileStatus, Context.getInstance().getApplicationSettings().getUserId());
    }
    
    private File generateFileStatus(FileNode root){
        List<File> childs = new ArrayList<>();
        for (FileNode fileNode : root.getChilds()) {
            childs.add(generateFileStatus(fileNode));
        }
        return new File(root.getName(), root.getVersion(), childs);
    }
    
}
